package com.ad.pet.app.collect.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ad.pet.R;
import com.ad.pet.common.data.utils.glide.GlideUtil;
import com.ad.pet.models.remote.collect.CollectShop;
import com.ad.pet.utils.LyxUtils;

import java.util.List;

/**
 * Created by SEELE on 2018/7/5.
 */

public class CollectShopAdapter extends BaseQuickAdapter<CollectShop,BaseViewHolder> {
    OnDelLinstener mOnDelLinstener;

    public CollectShopAdapter(@Nullable List<CollectShop> data) {
        super(R.layout.item_shop_collection_layout, data);
    }

    public void setOnDelLinstener(OnDelLinstener onDelLinstener) {
        mOnDelLinstener = onDelLinstener;
    }

    @Override
    protected void convert(final BaseViewHolder helper, CollectShop item) {
        ImageView ivHead = helper.getView(R.id.iv_head);
        ImageView ivLogo = helper.getView(R.id.iv_logo);
        LinearLayout linearLayout = helper.getView(R.id.linear_cancel);
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getStorename());
        GlideUtil.loadCircle(mContext, TextUtils.isEmpty(item.getStoreimage())? LyxUtils.getImgUrl(R.drawable.ic_default_shop):item.getStoreimage(),ivHead);
        ivLogo.setVisibility(View.INVISIBLE);
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnDelLinstener.del(helper.getLayoutPosition());
            }
        });

    }
    public interface OnDelLinstener{
        void del(int position);
    }
}
